<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .chart {
        width: 800px;
        height: 400px;
      }
    </style>
  </head>
  <body>
    <!-- 2. 准备一个具备宽高的容器 -->
    <div class="chart"></div>
    <!-- 1. 引入echarts js文件 -->
    <script src="https://cdn.bootcdn.net/ajax/libs/echarts/5.1.2/echarts.min.js"></script>
    <script>
      // 3. 初始化echarts实例
      const chart = echarts.init(document.querySelector('.chart'));
      // 4. 定义option 图表的配置项
      const option = {
        dataset: {
          source: [
            ['一季度', 79, 100, '分类1', 50],
            ['二季度', 81, 112, '分类2', 60],
            ['三季度', 88, 96, '分类3', 55],
            ['四季度', 72, 123, '分类4', 70],
          ],
        },
        xAxis: {
          type: 'category',
        },
        yAxis: {},
        series: [
          {
            type: 'line',
            encode: { x: 0, y: 1 },
          },
          {
            type: 'bar',
            encode: { x: 0, y: 2 },
          },
          {
            type: 'pie',
            encode: { itemName: 3, value: 4 },
            radius: 35,
            center: ['50%', 40],
          },
        ],
      };
      // 5. 调用setOption方法来生成图表
      chart.setOption(option);
    </script>
  </body>
</html>
